import os
import re
from fuzzywuzzy import fuzz
from flask import Flask
from aip import AipOcr
import bwc_my_sql
def recognization(image):
    new_result = list()
    APP_ID = '45300323'
    API_KEY = 'MflXR9IZdn5mrVIz2GGVQViz'
    SECRET_KEY = 'Wto0f3vuGo284XF0Vzq1cK84BjgHhx1v'

    client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
    result = client.basicGeneralUrl(image)
    try:
        ending = result["words_result"]
        # print(ending)
    except KeyError:
        print('异常')
        ending = [{'words': '图片'},{'words': '识别不能'}]
    new_list = []
    for word in ending:
        for value in word.values():
            new_list.append(value)
    # print(new_list)
    final_list = ''.join(new_list)
    final_list = re.sub(r'[（]{1,100}', ')', final_list)
    final_list = re.sub(r'[）]{1,100}', '(', final_list)
    # print(final_list)
    new_result.append(final_list)
    return final_list